home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / gui / BGUI11c.lha / docs / baseclass.doc next >
Text File  |  1995-04-23  |  17KB  |  404 lines

  1.  
  2.                File: baseclass.doc
  3.         Description: Baseclass documentation.
  4.           Copyright: (C) Copyright 1994-1995 Jaba Development.
  5.                      (C) Copyright 1994-1995 Jan van den Baard.
  6.                      All Rights Reserved.
  7.  
  8. ------------------------------------------------------------------------------
  9.  
  10. TABLE OF CONTENTS
  11.  
  12. baseclass/--background--
  13. baseclass/Methods
  14. baseclass/Attributes
  15.  
  16. baseclass/--background--                              baseclass/--background--
  17.  
  18.     NAME
  19.         Class:          baseclass
  20.         Superclass:     GADGETCLASS
  21.         Include File:   <libraries/bgui.h>
  22.  
  23.     FUNCTION
  24.         This is the most important gadget class in BGUI.  It is the superclass
  25.         of almost all the other gadget classes at one point  or the other.  It
  26.         will take care of the following things for it's subclasses:
  27.  
  28.         o Notification
  29.         o Frames
  30.         o Labels
  31.         o Online-help.
  32.  
  33.         If you plan on writing a class for BGUI then always sub-class in  from
  34.         this class. That way you automatically  inherrit the  above  mentioned
  35.         features.
  36.  
  37. baseclass/Methods                                            baseclass/Methods
  38.  
  39.     NOTE
  40.         The methods described here are also valid  for  the other  BGUI gadget
  41.         classes subclassed from this class unless documented otherwise.
  42.  
  43.     NEW METHODS
  44.         BASE_ADDMAP -- This method must be used to add a target  object to  an
  45.                 object it's maplist notification  list.   Maplist notification
  46.                 is  simular  to  the  notification  performed  by  the  system
  47.                 "icclass" and ICA_TARGET notification.  This  method  uses the
  48.                 following custom message structure:
  49.  
  50.                 struct bmAddMap {
  51.                         ULONG           MethodID;    /* BASE_ADDMAP */
  52.                         Object         *bam_Object;  /* Target object */
  53.                         struct TagItem *bam_MapList;
  54.                 };
  55.  
  56.                 bam_MapList --  This   can   point  to  an  array  of  TagItem
  57.                 structures which contains a  set of  attributes  to map.  This
  58.                 may also be NULL in which case no mapping is done.
  59.  
  60.                 Returns TRUE uppon success, FALSE uppon failure.
  61.  
  62.         BASE_ADDCONDITIONAL -- This method must be used to add a target object
  63.                 to an object it's conditional notification list.   Conditional
  64.                 notification is a simple "if attr a == b then set attr c to d"
  65.                 style of notification. Example:
  66.  
  67.                 Object          *cycle, *string;
  68.  
  69.                 DoMethod( cycle, BASE_ADDCONDITIONAL, string,
  70.                         CYC_Active,  0,
  71.                         GA_Disabled, FALSE,
  72.                         GA_Disabled, TRUE );
  73.  
  74.                 This  will  enable  the  string  gadget  when  the  CYC_Active
  75.                 attribute  of  the  cycle  gadget  is 0.   If  the  CYC_Active
  76.                 attribute is not 0 the string gadget is disabled.
  77.  
  78.                 This method uses the following custom message structure:
  79.  
  80.                 struct bmAddConditional {
  81.                         ULONG           MethodID;   /* BASE_ADDCONDITIONAL */
  82.                         Object         *bac_Object; /* Target object. */
  83.                         struct TagItem  bac_Condition;
  84.                         struct TagItem  bac_TRUE;
  85.                         struct TagItem  bac_FALSE;
  86.                 };
  87.  
  88.                 bac_Condition -- This attribute pair represents  the condition
  89.                         which has to be met.
  90.  
  91.                 bac_TRUE -- This attribute pair is set to the target object if
  92.                         the condition is TRUE (I.E. met).
  93.  
  94.                 bac_FALSE -- This attribute pair is set to  the target  object
  95.                         if the condition is FALSE (I.E. not met).
  96.  
  97.                 Returns TRUE uppon success, FALSE uppon failure.
  98.  
  99.         BASE_ADDMETHOD -- This method must be used to  add a target  object to
  100.                 an object it's method notification list.   Method notification
  101.                 allows  you  to  send a  complete  method to a  target  when a
  102.                 notification  event occures.   This method uses  the following
  103.                 custom message structure:
  104.  
  105.                 struct bmAddMethod {
  106.                         ULONG           MethodID;   /* BASE_ADDMETHOD */
  107.                         Object         *bam_Object; /* Target object. */
  108.                         ULONG           bam_Flags;
  109.                         ULONG           bam_Size;
  110.                         ULONG           bam_MethodID;
  111.                 };
  112.  
  113.                 bam_Flags -- This may contain any of the following flags:
  114.  
  115.                         BAMF_NO_GINFO -- Normally a pointer  to  a  GadgetInfo
  116.                                 structure is inserted in  the method  to send.
  117.                                 When this flag is set this  will not  be done.
  118.                                 Please note that  when a GadgetInfo  is placed
  119.                                 it is done as follows:
  120.  
  121.                                 OM_NEW, OM_SET, OM_UPDATE, OM_NOTIFY -- If the
  122.                                         method to  send  is  any of  these the
  123.                                         GadgetInfo  is  placed  in  the  third
  124.                                         long word of  the  method.  All  other
  125.                                         methods will get the GadgetInfo in the
  126.                                         second long word.  This  behaviour  is
  127.                                         the same as with DoGadgetMethodA().
  128.  
  129.                         BAMF_NO_INTERIM -- When set  the  method  will not  be
  130.                                 send on interim notification events.
  131.  
  132.                 bam_Size -- This field must contain the number  of  long-words
  133.                         _including_ the method ID of the method to send.  This
  134.                         information is needed because a copy of  the method to
  135.                         send is made in an internal buffer.
  136.  
  137.                 bam_MethodID -- This must be  the  ID of the  method to  send.
  138.                         This  field  can  be  followed  by the method specific
  139.                         data.
  140.  
  141.                 Please  note   that   most  notification  will  occure on  the
  142.                 input.device it's task. This means that the called method must
  143.                 not  take  to  long  to  return  and  generally  should not do
  144.                 anything a normal input handler should not do.
  145.  
  146.                 Returns TRUE uppon success, FALSE uppon failure.
  147.  
  148.         BASE_REMMAP,  BASE_REMCONDITIONAL,   BASE_REMMETHOD,   BASE_REMHOOK --
  149.                 These methods must be used to remove a target object/hook from
  150.                 any of the notification lists.  This method uses the following
  151.                 message structure:
  152.  
  153.                 struct bmRemove {
  154.                         ULONG           MethodID;   /* Any of the above. */
  155.                         Object         *bar_Object; /* Object to remove. */
  156.                 };
  157.  
  158.                 Return code not defined.
  159.  
  160.         BASE_SETLOOP,     BASE_CLEARLOOP,     BASE_CHECKLOOP,    BASE_LEFTEXT,
  161.         BASE_SHOWHELP -- These methods are private and  should not  be of  any
  162.                 use to you.
  163.  
  164.         BASE_ADDHOOK -- This method must be used to add a  hook routine to the
  165.                 object it's hook-notification list.   Hook notification allows
  166.                 you to add a routine via  a Hook  to the  notification  of the
  167.                 object. In other words, the hook will be  called  whenever the
  168.                 object  sends  out  a  notification.   This  method  uses  the
  169.                 following custom message structure:
  170.  
  171.                 struct bmAddHook {
  172.                         ULONG           MethodID; /* BASE_ADDHOOK */
  173.                         struct Hook    *bah_Hook;
  174.                 };
  175.  
  176.                 bah_Hook -- A pointer to the Hook structure.
  177.  
  178.                 Your hook routine will be called as follows:
  179.  
  180.                 rc = hookFunc( hook, obj, update );
  181.                 D0             A0    A2   A1
  182.  
  183.                 hook -- This will point to the Hook structure.
  184.  
  185.                 obj -- This  is  a  pointer  to  the  object  that  caused the
  186.                         notification.
  187.  
  188.                 update -- This is a pointer to a opUpdate structure from which
  189.                         you can extract data like the  visual  environment and
  190.                         notified attribute changes.
  191.  
  192.                 Your hook routine must return non-zero  when the  notification
  193.                 caused a change of some sort and zero if not.
  194.  
  195.                 Returns TRUE uppon success and FALSE uppon failure.
  196.  
  197.     SEE ALSO
  198.         intuition.library/DoGadgetMethodA(), icclass, ICA_TARGET,
  199.         utility/hooks.h
  200.  
  201.     CHANGED METHODS
  202.         OM_UPDATE -- This method fixes a bug in the system  GADGETCLASS.  Even
  203.                 though the documentation states that the GA_ID  attribute of a
  204.                 gadget object cannot  be  changed  by a  OM_UPDATE  message it
  205.                 still does.  As this behaviour  is not  correct  the baseclass
  206.                 intercepts the GA_ID  attribute  before passing  it on to  the
  207.                 GADGETCLASS.  This  way  GA_ID  will  not  be  changable  by a
  208.                 OM_UPDATE call.
  209.  
  210.         OM_NOTIFY -- This method will first  execute all maplist, conditional,
  211.                 method and hook notification.  When that  is  done the  method
  212.                 is passed onto  GADGETCLASS  for any  ICA_TARGET's that  might
  213.                 still exist.
  214.  
  215.         GM_RENDER -- If this message requests a  complete  re-rendering  (I.E.
  216.                 GREDRAW_REDRAW) this method will  render the  frame  and label
  217.                 when available. On any other request it will simply re-compute
  218.                 the gadget hitbox bounds.  When this method returns a non-NULL
  219.                 value you are also allowed to render.   If this method returns
  220.                 NULL then you may not render.
  221.  
  222.                 Your   class  _must_  also  follow  the  same  rules.  If  the
  223.                 superclass  of  your  class returns NULL you do not render and
  224.                 also  return  NULL.  If the superclass of your class returns a
  225.                 non-NULL  value  you  should render and also return a non-NULL
  226.                 value.
  227.  
  228.                 Your class must  use  the gpr_RPort field for _all_ rendering.
  229.                 This usually points to a buffer rastport in  which  you render
  230.                 without it showing on screen.  This  also  means  that if your
  231.                 class uses OM_SET on another  object  you  must do  so without
  232.                 passing the gpr_GInfo field and re-render that object later in
  233.                 the RastPort pointed to by the gpr_RPort field.
  234.  
  235.                 RastPort-Clipping is not allowed for BGUI objects.  The reason
  236.                 for this limitation is that all rendering occures in  a buffer
  237.                 rastport  without  a  layer  attached  to  it.   If your class
  238.                 absolutely needs clipping you must  use the  WINDOW_NoBufferRP
  239.                 or PAGE_NoBufferRP on  the window  object  or page  object  in
  240.                 which the object is located.
  241.  
  242.         GM_HITTEST -- This method will return  GMR_GADGETHIT  when  the gadget
  243.                 was clicked inside it's hitbox bounds.
  244.  
  245.     SEE ALSO
  246.         <intuition/gadgetclass.h>
  247.  
  248. baseclass/Attributes                                      baseclass/Attributes
  249.  
  250.     NOTE
  251.         The attributes described here are also valid for the other BGUI gadget
  252.         classes subclassed from this class unless documented otherwise.
  253.  
  254.     NAME
  255.         BT_HelpFile -- ( STRPTR )
  256.  
  257.     FUNCTION
  258.         Set the name of the file to be displayed when a  help-request  for the
  259.         object arives. Please note that the full path-name must be given.
  260.  
  261.         Default is NULL. Applicability is (IS).
  262.  
  263.     SEE ALSO
  264.         BT_HelpNode, BT_HelpLine
  265.  
  266.     NAME
  267.         BT_HelpNode -- ( STRPTR )
  268.  
  269.     FUNCTION
  270.         Set the name of the node which is diplayed in the help window.
  271.  
  272.         Default is NULL. Applicability is (IS).
  273.  
  274.     SEE ALSO
  275.         BT_HelpFile, BT_HelpLine
  276.  
  277.     NAME
  278.         BT_HelpLine - ( ULONG )
  279.  
  280.     FUNCTION
  281.         Set the line number  from  which the  file is  displayed.  This may be
  282.         useful if the help-file is not an AmigaGuide file.
  283.  
  284.         Default is 0. Applicability is (IS).
  285.  
  286.     SEE ALSO
  287.         BT_HelpFile, BT_HelpNode
  288.  
  289.     NAME
  290.         BT_HitBox - ( struct IBox * )
  291.  
  292.     FUNCTION
  293.         Get the hitbox bounds of the gadget object. This attribute is normally
  294.         only usefull for class writers.  Please  note that the contents of the
  295.         returned IBox  structure  is only  valid  _after_  you let  this class
  296.         render itself. For example suppose the  following  code is  your class
  297.         dispatcher:
  298.  
  299.         __saveds __asm ULONG
  300.         dispatcher ( __a0 Class *cl, __A2 Object *obj, __A1 Msg msg )
  301.         {
  302.                 struct IBox             *domain;
  303.  
  304.                 switch ( msg->MethodID ) {
  305.  
  306.                         ...
  307.  
  308.                         case    GM_RENDER:
  309.                                 /*
  310.                                 **      First let the superclass render.
  311.                                 **/
  312.                                 if ( ! DoSuperMethodA( cl, obj, msg ))
  313.                                         return( 0L );
  314.                                 /*
  315.                                 **      Now you can obtain the object
  316.                                 **      it's hitbox bounds.
  317.                                 **/
  318.                                 DoSuperMethod( cl, obj, OM_GET,
  319.                                                BT_HitBox, &domain );
  320.  
  321.                                 ...
  322.  
  323.                                 break;
  324.                 }
  325.         }
  326.  
  327.         Please note that the pointer returned is READ-ONLY.  If  you  need  to
  328.         adjust it's contents you should make a private copy of the data.
  329.  
  330.         Applicability is (G).
  331.  
  332.     NAME
  333.         BT_LabelObject, BT_FrameObject -- ( Object * )
  334.  
  335.     FUNCTION
  336.         Set or get the frame/label object to use. Normally only  class writers
  337.         use these attributes.  You can use  them to  obtain a  pointer  to the
  338.         label/frame object or to erase/change the label/frame object.  If, for
  339.         example, your class uses it's own custom rendering you can  dispose of
  340.         the baseclass frame by setting it to NULL like this:
  341.  
  342.         SetAttrs( object, FRM_FrameObject, NULL, TAG_END );
  343.  
  344.         Default  is  the  frame/label  build from the attributes passed to the
  345.         object at create time. Applicability is (SG).
  346.  
  347.     SEE ALSO
  348.         intuition.library/SetAttrs()
  349.  
  350.     NAME
  351.         BT_TextAttr -- ( struct TextAttr * )
  352.  
  353.     FUNCTION
  354.         Set the font which will be used by the frame and  label of  the class.
  355.         Class writers might  want  to  intercept  and  copy  this data  before
  356.         passing it onto the superclass.
  357.  
  358.         Default is NULL. Applicability is (S).
  359.  
  360.     NAME
  361.         BT_NoRecessed -- ( BOOL )
  362.  
  363.     FUNCTION
  364.         To tell the baseclass not to recess the frame when the  gadget  object
  365.         is selected. The checkboxclass uses this attribute.
  366.  
  367.     NAME
  368.         BT_LabelClick -- ( BOOL )
  369.  
  370.     FUNCTION
  371.         To  tell  the  baseclass  to  also consider clicking inside the gadget
  372.         label as a hit.
  373.  
  374.         Default is FALSE. Applicability is (I).
  375.  
  376.     SEE ALSO
  377.         Methods/GM_GADGETHIT
  378.  
  379.     NOTE
  380.         All frameclass and labelclass attributes are also valid  when creating
  381.         a baseclass object.
  382.  
  383.     NAME
  384.         BT_HelpText -- ( STRPTR)
  385.  
  386.     FUNCTION
  387.         To setup  a  text  which  will be displayed if the help-key is pressed
  388.         while the  mouse  pointer  is located above the object. This attribute
  389.         should be  used  to  attach small on-line help to the object. The text
  390.         you specify will be shown in a small BGUI_RequestA() type of requester
  391.         so you  must  make  sure  that  everything  fit's  nicely on a 600x200
  392.         screen.
  393.  
  394.         The specified text may contain any of the infoclass command sequences.
  395.  
  396.         This attribute overides the BT_HelpFile,  BT_HelpNode and  BT_HelpLine
  397.         attributes.
  398.  
  399.         Default is NULL. Applicability (IS).
  400.  
  401.     SEE ALSO
  402.         BT_HelpFile, BT_HelpNode, BT_HelpLine, infoclass/INFO_TextFormat,
  403.         bgui.library/BGUI_RequestA()
  404.